<?php
namespace app\time\controller;
use app\time\moudel\Time_img;
use app\time\moudel\Time;
use think\Controller;
use think\Request;
/**
 * 
 */
class Light extends Controller
{
	
	public $time;
	public $img;
	public $date;
	public function __construct(){
		parent::__construct();
		$this->date=date('Y--m-d H:i:s',time());
		$this->time=new Time();
		$this->img=new Time_img();
	}

	public function json($status,$message,$data=''){
		if (empty($data)) {
			$arr=array(
			'status' => $status,
			'message' => $message
		    );
		}else{
			$arr=array(
			'status' => $status,
			'message' => $message,
			'data' => $data
			);
		}
		return json_encode($arr);
	}

	public function test(){
		$this->time->check();
	}

	public function add(Request $request){
		$data=$request->post();
		$path=action('upload/tootal/base_updata',$data['data']);
		$tarr=array(
			'userid' => $data['userid'],
			'time_name' => $data['time_name'],
			'create_time' => $this->date
		);
		$iarr=array(
			'userid' => $data['userid'],
			'time_name' => $data['time_name'],
			'img' => $path['bigname'],
			'smali_img' => $path['smallname'],
			'video' => $data['video']
		);
		$tlt=$this->time->insert($tarr);
		$ilt=$this->img->insert($iarr);
		if ($tlt==true && $ilt==true) {
			$this->json(true,'添加成功',array('bigpath'=>$path['bigpath'],'smallpath'=>$path['smallpath']));
		}
		$this->json(false,'添加失败');
	}

	public function getdata(){

	}
}